import * as reviewApi from '@/api/review'; // 假设你的 review.js 在 api 目录下

export default {
  //工作概览
  async fetchStatic({ commit }, params) {
    try {
      console.log('统计数据开始获取');
      const responseStatic = await reviewApi.statics(params);
      commit('setStatics', responseStatic.data);
      console.log('统计数据获取成功');
    } catch (error) {
      console.error('Error fetching review list:', error);
    }
  },

  async fetchStaticAll({ commit }, params) {
    try {
      console.log('统计数据开始获取');
      const responseStatic = await reviewApi.statics(params);
      const responseReviewer = await reviewApi.reviewer();

      commit('setStatics', responseStatic.data);
      commit('setReviewerList', responseReviewer.data);
      console.log('统计数据获取成功');
    } catch (error) {
      console.error('Error fetching review list:', error);
    }
  },
  //工作台
  async fetchUndo({ commit }, params) {
    try {
      console.log('工作台数据开始获取');
      const responseUndo = await reviewApi.undo(params);

      commit('setUndoList', responseUndo.data);
      console.log('工作台数据获取成功');
    } catch (error) {
      console.error('Error fetching undo list');
    }
  },

  //审核列表
  //获取审核列表（给审核）
  async fetchList({ commit }, params) {
    try {
      console.log('后台列表开始获取');
      const response = await reviewApi.tasks(params);
      commit('setReviewList', response.data);
      console.log('后台列表获取成功');
    } catch (error) {
      console.error('Error fetching review list:', error);
      // 处理错误，比如提示用户或者记录日志
    }
  },

  //获取所有审核信息（给管理员）
  async fetchAll({ commit }, params) {
    try {
      const responseList = await reviewApi.list(params);
      commit('setReviewList', responseList.data);
    } catch (error) {
      console.error('Error fetching review list:', error);
    }
  },
};
